package service

import (
	"context"
	"go-shop-api/internal/dao"
	"go-shop-api/pkg/e"
	"go-shop-api/pkg/serializer"
)

//轮播图

type BannerService struct {
	//场景 1 首页轮播
	Scene uint `json:"scene" form:"scene" binding:"required,numeric"`
}

func (s *BannerService) List(ctx context.Context) *serializer.Response {
	//组装where筛选条件
	whereMap := dao.WhereStruct{
		Where: map[string]interface{}{
			"scene": s.Scene,
		},
	}

	bannerDao := dao.NewBannerDao(ctx)
	total, list, err := bannerDao.GetList(whereMap)
	if err != nil {
		return serializer.NewResponse(e.Error, err.Error(), e.TipsGeneral, nil)
	}
	return serializer.BuildListResponse(total, serializer.BuildListBanner(list), e.TipsOk, e.TipsSuccessOperate)
}
